home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / dskut / boops.zip / BOOPS.ASM next >
Assembly Source File  |  1992-02-01  |  6KB  |  258 lines

  1. title    Boops -- Floppy Boot Bypasser
  2. page    ,132
  3.  
  4. comment    #
  5.  
  6.  
  7.     BOOPS  Floppy Boot Bypasser  (c) 1992, Urmas Rahu
  8.     
  9.     This program modifies the boot sector of a diskette so that the
  10.     floppy may be in the drive at bootup, and the PC would still boot
  11.     from the hard drive.  The boot code simply loads the master boot
  12.     sector of the first hard disk into memory and passes control to it.
  13.     
  14.     This program was inspired by Bill Gibson's similar product, BootThru.
  15.     The problem with his program (ver 1.05, 1987) was that it supports
  16.     360KB floppies only.  My program should work equally well on all
  17.     floppy formats.  The only requirement is, that the disketts must
  18.     have the standard 512-byte sectors.  You should not use this program
  19.     to modify copy-protected floppies.
  20.  
  21.     Syntax:        BOOPS drive:
  22.  
  23.             The colon after the drive letter is required.
  24.  
  25.  
  26.     Date:        Feb-01-1992
  27.  
  28.     #
  29.  
  30.  
  31.  
  32.  
  33. SECSIZE        equ    512            ; standard sector size
  34. OFF_SECSIZE    equ    2            ; offset of sec size field in
  35.                         ;  disk info block
  36.  
  37.  
  38. code segment
  39. assume cs:code, ds:code, ss:code
  40.  
  41. org 100h
  42. entry:        jmp    start    
  43.  
  44.  
  45. bootsector:    jmp    short bootcode        ; boot sector starts here
  46.         nop
  47.  
  48. bootdata    db    1bH dup (?)        ; near jump to boot code
  49.  
  50. comment #    this stuff was in BootThru, i couldn't figure its purpose
  51. .radix 16
  52. ;        db    0,0,0a
  53. ;        db    0df,02,25,02,09,2a,0ff,50,0f6,0f,02
  54. .radix 10 #
  55.  
  56.  
  57. hdload:        mov    ax, 0201H        ; this part of code will be
  58.         mov    bx, 07c0H        ;  copied to 07c0:0200, just
  59.         mov    es, bx            ;  above the boot sector image,
  60.         xor    bx, bx            ;  so that the hard disk boot
  61.         mov    cx, 0001H        ;  sector will fit right below
  62.         mov    dx, 0080H        ;  it.
  63.         int    13H            ; read hard drive's boot record
  64.  
  65.         db    0e9H            ; jump to hard disk boot code
  66.         dw    -SECSIZE - (hdload_end-hdload)    ; (at 07c0:0000)
  67. hdload_end    label    byte
  68.  
  69. bootcode:                    ; start of my boot code
  70.         mov    bx, 07c0H
  71.         mov    ds, bx            ; set segment regs to 07c0
  72.         mov    es, bx
  73.         
  74.         mov    bx, message - bootsector
  75.         mov    ah, 0eH
  76.  
  77. dispmsg:    mov    al, [bx]        ; show message of bypassing
  78.         cmp    al, 0
  79.         jz    copycode
  80.         int    10H            ; write teletype
  81.         inc    bx
  82.         jmp    short dispmsg    
  83.  
  84. copycode:    mov    si, hdload - bootsector    ; copy the hard disk boot sector
  85.         mov    di, SECSIZE        ;  loader to 07c0:0200
  86.         mov    cx, bootcode - hdload
  87.         cld
  88.     rep    movsb
  89.         
  90.         db    0e9H            ; jump to hard disk boot sector
  91.         dw    SECSIZE - (copycode_end - bootsector)    ; loader
  92. copycode_end    label    byte            ; (at 07c0:0200)
  93.  
  94.  
  95.  
  96. message        db    13,"BOOPS  (c) 1992, Urmas Rahu:  "
  97.         db    "Bypassing floppy boot . . .  ",13,10,0
  98.  
  99.         db    "                                                  "
  100.         db    "   BOOPS -- Floppy Boot Bypasser   Version 1.0"
  101.         db    "   (c) 1992, Urmas Rahu    My address is:"
  102.         db    " Tammsaare 57-27, EE0034 Tallinn, Estonia.   "
  103.         db    " Write for information about our products.   "
  104.  
  105.         db    "                    "
  106.         db    ' "For those about to rock / We salute you"   (AC/DC)  '
  107.  
  108. filler        db    SECSIZE - (filler-bootsector) dup (' ')
  109.  
  110.  
  111.  
  112. old_bootdata:    db    1eH dup (?)        ; old boot sector will be 
  113. old_bootcode:    db    (512-1eH) dup (?)    ;  read here
  114.  
  115.  
  116.  
  117.  
  118.  
  119. start:        jmp    go
  120.  
  121. msg_title    db    "Boops  --  Floppy Boot Bypasser  (c) 1992, Urmas Rahu"
  122.         db    13,10,'$'
  123.  
  124. msg_usage    db    13,10
  125.         db    "Usage:     BOOPS drive:"
  126.         db    13,10
  127.         db    "Function:  This program will modify the boot sector of",13,10
  128.         db    "           a floppy disk so that the computer will boot from",13,10
  129.         db    "           the hard disk even if a floppy is in the drive.",13,10
  130.         db    '$'
  131.  
  132. msg_run        db    "Writing boot sector of drive "
  133. msg_run_drive    db    "@: . . . $"
  134.  
  135. msg_done    db    "OK, completed.   $"
  136.  
  137. msg_failed    db    "Disk access failed, aborted.   $"
  138.  
  139. msg_nonstdsec    db    "Non-standard sector size, aborted.   $"
  140.  
  141. msg_invalid_dr    db    "Invalid drive, aborted.   $"
  142.  
  143.  
  144.  
  145. drive        db    0
  146.  
  147. jmp2du:        jmp    disp_usage        ; jmp-jmp
  148.  
  149.  
  150. go:        mov    ah, 9
  151.         mov    dx, offset msg_title
  152.         int    21H            ; show title
  153.  
  154.         mov    di, 81H            ; point at UPA
  155.         xor    ch, ch
  156.         mov    cl, cs:80H        ; count of chars at UPA
  157.         jcxz    jmp2du            ; empty command line
  158.         mov    al, ':'            ; search for colon at cmd line
  159.         cld
  160.     repne    scasb
  161.         jnz    disp_usage        ; no colon, no drive: disp help
  162.  
  163.         mov    dl, byte ptr [di-2]    ; point at drive character
  164.         and    dl, 0dfH        ; convert to uppercase
  165.         sub    dl, 41H            ; convert to drive number
  166. ;        test    dl, 0feH        ; only 0 and 1 allowed
  167. ;        jnz    disp_usage
  168.  
  169.         mov    msg_run_drive, dl    ; insert drive letter
  170.         add    msg_run_drive, 41H
  171.         mov    drive, dl        ; save drive number
  172.         mov    dx, offset msg_run
  173.         mov    ah, 9
  174.         int    21H            ; show message of running
  175.  
  176.         push    ds            ; save ds
  177.         mov    ah, 32H            ; call undocumented DOS fn
  178.         mov    dl, drive
  179.         inc    dl            ; (A: is 1, etc)
  180.         int    21H            ; get disk info !!DS destroyed!!
  181.         cmp    al, 0            ; ok?
  182.         jnz    bad_drive        ; invalid drive
  183.  
  184.         cmp    word ptr [bx+OFF_SECSIZE], SECSIZE
  185.         jne    bad_secsize        ; sector size not 512 bytes        
  186.  
  187.         pop    ds            ; restore ds
  188.  
  189.         mov    ax, 0201H        ; read boot sector with BIOS
  190.         mov    dh, 0
  191.         mov    dl, drive
  192.         mov    cx, 0001H
  193.         mov    bx, cs
  194.         mov    es, bx
  195.         mov    bx, offset old_bootdata
  196.         push    es
  197.         push    bx
  198.         int    13H
  199.         jc    disk_failed
  200.                 
  201.         pop    si            ; point at old boot sector
  202.         add    si, 3            ; skip the jmp instruction
  203.         pop    bx            ; segment
  204.         mov    ds, bx
  205.         mov    es, bx
  206.         mov    di, offset bootdata
  207.         mov    cx, 1bH            ; copy old data from boot sector
  208.         cld
  209.     rep    movsb
  210.         
  211.         mov    bx, offset bootsector    ; write new boot sector
  212.         mov    ax, 0301H
  213.         mov    dh, 0
  214.         mov    dl, drive
  215.         mov    cx, 0001H
  216.         int    13H
  217.         jc    disk_failed
  218.  
  219.         mov    dx, offset msg_done
  220.         mov    ah, 9
  221.         int    21H            ; completed message
  222.  
  223.         mov    ax, 4c00H        ; exit code 0
  224.         int    21H
  225.  
  226. disp_usage:    mov    ah,9
  227.         mov    dx, offset msg_usage
  228.         int    21H
  229.  
  230.         mov    ax, 4c01H        ; exit code 1
  231.         int    21H
  232.  
  233.  
  234. disk_failed:    mov    ah, 9
  235.         mov    dx, offset msg_failed
  236.         int    21H
  237.  
  238. exit_2:        mov    ax, 4c02H        ; exit code 2
  239.         int    21H
  240.  
  241. bad_drive:    pop    ds            ; remember?
  242.         mov    ah, 9
  243.         mov    dx, offset msg_invalid_dr
  244.         int    21H
  245.         jmp    short exit_2
  246.  
  247. bad_secsize:    pop    ds            ; remember ds?
  248.         mov    ah, 9            
  249.         mov    dx, offset msg_nonstdsec
  250.         int    21H
  251.         jmp    short exit_2
  252.  
  253.  
  254. code ends
  255.  
  256. end entry
  257.  
  258.